#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
class Solution {
public:
    string addStrings(string nums1, string nums2)
    {
        int end1 = nums1.size() - 1, end2 = nums2.size() - 1;
        string retstr;
        int next = 0;
        while (end1 >= 0 || end2 >= 0)
        {
            int val1 = end1 >= 0 ? nums1[end1--] - '0' : 0;
            int val2 = end2 >= 0 ? nums2[end2--] - '0' : 0;
            int ret = val1 + val2 + next;
            next = ret / 10;
            ret = ret % 10;
            retstr.insert(0, 1, ret + '0');

        }
        if (next == 1)
            retstr.insert(retstr.begin(), '1');
        return retstr;
    }


};